package com.sy.workflow.service.service;

import org.springframework.stereotype.Service;

import com.sy.core.bean.CommonResult;
import com.sy.gcp.user.center.api.dto.GcpUserDTO;
import com.sy.gcp.user.center.api.feign.UserCenterFeign;
import com.sy.workflow.core.api.WfUserApi;
import com.sy.workflow.core.dto.FlowUser;

import cn.hutool.core.util.NumberUtil;
import cn.hutool.extra.spring.SpringUtil;

@Service
public class WfUserApiService implements WfUserApi {

	@Override
	public FlowUser getFowUser(String userId) {
		
		if(!NumberUtil.isLong(userId))
			return null;
		
		UserCenterFeign feign = SpringUtil.getBean(UserCenterFeign.class);
		
	    CommonResult<GcpUserDTO> rst = feign.findGcpUserById(Long.parseLong(userId));
		
		GcpUserDTO user =  rst.checkAndGetData();
		
		return new FlowUser(user.getId(), user.getUserName(), user.getDepartId(), user.getDepartName(), null, null);
	}

	
	
	
}
